import http from './base'

const api = {
    questions: '/api/exams/questions',  //  题目
    submitQuestions: '/api/exams/submit_answers',   //  提交答案
}

function questions(param) {
    return http.get(api.questions, param)
}

function submitQuestions(param) {
    return http.post(api.submitQuestions, param)
}

function response(promise, callback) {
    promise.then(res => {
        return callback && callback([res.status, res.data])
    }).catch(error => {
        console.log(error)
        
    })
}

function questionsServer(param, callback) {
    response(questions(param), callback)
}

function submitQuestionsServer(param, callback) {
    response(submitQuestions(param), callback)
}

export default {
    questionsServer,
    submitQuestionsServer
}